package com.quanshu.shop.main.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.quanshu.exchange.R;

/**
 * 作者  李哲
 * 创建时间 2018/7/17
 * 邮箱 lizhetongliao@163.com
 * 说明
 **/
public class Title1Adapter extends DelegateAdapter.Adapter<Title1Adapter.TitleView1Holder> {
    private Context mContext;
    private String title;
    private LayoutHelper layoutHelper;
    public static final int TITLE1_TYPE = 7;

    public Title1Adapter(Context mContext, String title, LayoutHelper layoutHelper) {
        this.mContext = mContext;
        this.title = title;
        this.layoutHelper = layoutHelper;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return layoutHelper;
    }

    @NonNull
    @Override
    public TitleView1Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        if (viewType == TITLE1_TYPE) {
            return new TitleView1Holder(LayoutInflater.from(mContext).inflate(R.layout.item_shop_title1, parent, false));
        }
        return null;
    }

    @Override
    public void onBindViewHolder(@NonNull TitleView1Holder holder, int position) {
        holder.textView.setText(title);
    }

    @Override
    public int getItemViewType(int position) {
        return TITLE1_TYPE;
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    class TitleView1Holder extends RecyclerView.ViewHolder {
        TextView textView;

        public TitleView1Holder(View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.shop_title1_txt);
        }
    }
}
